var targetUrl = 'http://m.yit.com/wechat/show/35/0'

var request = require('superagent')

var reg=/<a .*?href=\"http:\/\/mp.weixin.qq.com\/s.*?>.*?<\/a>/g
var reg1 = /href=\".*?\"/g
// ('<p style=.*?>([\\s\\S]*)?</p>')

var categoryList = []
request
  .get(targetUrl)
  .end(function(err, res) {
    if (res.ok) {
      var html = res.text
      result = html.match(reg)
      console.log(result.length)
      result.forEach(function (item, index) {
        var p1 = item.indexOf('>')
        var p2 = item.indexOf('</a>')
        var subText = item.slice(p1 + 1, p2)
        if (subText.length > 0) {
          var title = subText
          var urlMatch = item.match(reg1)
          var url = urlMatch[0].slice(6, urlMatch[0].length - 1)
          categoryList.push({
            title: title,
            url: url
          })
        }        
      })
      console.log(categoryList)
    }
  })


//

// [ { title: '是时候放它出来和大闸蟹决一死战了！',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=226611058&idx=1&sn=f523d3b8272901103efabcbdb0bb76ca#rd' },
//   { title: '别告诉我你小时候没吃过这个',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=225617538&idx=1&sn=db21a87029a0c8ac0436209dd24a1235#rd' },
//   { title: '一口入魂的川香凉面',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=213586118&idx=1&sn=2bc005ee71f6427107b777ba3b42a043&scene=2&from=timeline&isappinstalled=0#rd' },
//   { title: '如果你说吃过这个，就暴露年龄了',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=212979264&idx=1&sn=f0ef65d793c7f78b30d205a19372a9d9&scene=4#wechat_redirect' },
//   { title: '吃货敢于直面一切暗黑料理，但这个也太好看了',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=212682134&idx=1&sn=87e7fa85756605dc66eaf7c5ab20ad98#rd' },
//   { title: '99%的人认为这是最下饭的菜',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=210757885&idx=1&sn=efe2c5931a6bbd1637184b45c9aa5307#rd' },
//   { title: '只有万分之一的吃货会做这道鸡翅',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=210253865&idx=1&sn=f8dff6c28d824a5f1711a973bbe5c3eb#rd' },
//   { title: '去湘菜馆，人人必点的一道菜',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=209812005&idx=1&sn=0b84c4a10e1781f765eb5fb2fec38f47#rd' },
//   { title: '年饱后，你最想吃什么？',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=209599751&idx=1&sn=e2b560ceb37610e8572289f0f4c8d224&key=8ea74966bf01cfb653c68fbd02d353f17e52e23fa1a8391f1b334dcc3965b5a252adde9d1cf403aef3dfc617411f4ad7&ascene=0&uin=MjQ0ODg0MTY2MQ%3D%3D&devicetype=iMac+MacBookPro10%2C1+OSX+OSX+10.10.2+build(14C109)&version=11020012&pass_ticket=W6G%2FH2iY4R2xD2JN9J2L%2BUea%2B%2FxOubtRY6Lf7vhlt4b2EXG5FSfeJ1r7HEHb7tp%2B' },
//   { title: '蒸鸡蛋羹，整出很多细孔或者皱巴巴，你就输了',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=208593956&idx=1&sn=c4069ba1aa1ff3ec990881a818bf5e96#rd' },
//   { title: '过年，一家子总得有个人会包汤圆吧',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=207455454&idx=1&sn=13c89d706a8d04695b23795a17e5e223&key=79cf83ea5128c3e5b2afcac9d40f5c02aaf6b465c395fb67e99fcdc57a2f4f509cf2fe15fcc6e832668350a0734d3131&ascene=0&uin=MTY0NDI0MzM2MA%3D%3D&devicetype=iMac+MacBookPro11%2C2+OSX+OSX+10.9.3+build(13D65)&version=11000006&pass_ticket=Tr5eEj6QZZpxK4LeW1kieBONET8%2BXqrkRKw4RQyc%2FLdRFLvaNAcjQUeRKLgkiB5Z' },
//   { title: '木樨肉，一把盐',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=205809923&idx=1&sn=4b3475de7793b2ec0ac9d2c87b020bcc&key=2f5eb01238e84f7ea795b6d5a3ef2ccb6cddc749bcdadf1e9e53842ca4ebb2c2df3e812135fcfcfcb02d0f03f2186fd3&ascene=0&uin=MjQ0ODg0MTY2MQ%3D%3D&devicetype=iMac+MacBookPro11%2C2+OSX+OSX+10.9.3+build(13D65)&version=11000006&pass_ticket=o3ylasLohyUhvqllCoNpcf9T1wnIaeU%2B42ssD7OPpeNxOJbU9VLhxAjEHXis28bj' },
//   { title: '这道鲫鱼豆腐，吃的就是豆腐',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=205433158&idx=1&sn=e1ae229b36914c7802a4b2c8cd00c30a&scene=2&from=timeline&isappinstalled=0#rd' },
//   { title: '这样做鸡腿，99.9%的人都没听过',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=204946783&idx=1&sn=0cf1c5ce7d3d41b8e1a7dea2062d5504#rd' },
//   { title: '又香又嫩的葱油鸡，煮6分钟就老啦！',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=204765065&idx=1&sn=f959d385ac70a73e1544782776b08f74#rd' },
//   { title: '一道八百年前的创意菜',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=203700030&idx=1&sn=d32a2aa46b596e765d3226f8f854ede0&scene=1&srcid=1124xHmlWQZFEDlf5FxUbfLk&from=singlemessage&isappinstalled=0#wechat_redirect' },
//   { title: '一斤好蟹，当以一斤陈年花雕醉之',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=203570893&idx=1&sn=8c65aab92ab0a372cf7bf458fb7b5e9c&scene=1&srcid=1124Mnj5UwFUYBYVTOMDfTfM&key=64fff292de787d7d2d18999173deab9bc7cf80e4999d8faab152fbbd9dc091f978df5c5a2cd9a9470e634f318a2f5ecc&ascene=0&uin=MjQ0ODg0MTY2MQ%3D%3D&devicetype=iMac+MacBookPro10%2C1+OSX+OSX+10.10.5+build(14F27)&version=11020201&pass_ticket=zgIFymVd8BQkmTq5WBkIcBKS8NFH%2BHMkCa6NireRAi8Jku1l2mXGBpl88Dghjj9a' },
//   { title: '中国古代版的方便面',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=203444048&idx=1&sn=4f03baea810d5d80c2641bafc7955b74&scene=1&srcid=11242tyQh4sqCdGSEg04plWZ&from=singlemessage&isappinstalled=0#wechat_redirect' },
//   { title: '那一碗醉生梦死的秃黄油',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=203346156&idx=1&sn=4ed5a6b44e8853ce1a163b4b4958a0bc&scene=1&srcid=112412STFOJd9oWle0wMMbu4&from=singlemessage&isappinstalled=0#wechat_redirect' },
//   { title: '一块被充分按摩过的大排才够嫩',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=204323806&idx=1&sn=faa28f8550cc106df483efc5779f9678#rd' },
//   { title: '国民红烧肉',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=203722458&idx=1&sn=c8e44f548d3a5adbe5f70da3afa6045b&scene=2&from=timeline&isappinstalled=0#rd' },
//   { title: '吃遍全台湾，还是我这碗肉燥饭最香',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=203289155&idx=1&sn=f54328bc4c55ee96f790553b0b77a569#rd' },
//   { title: '毫不费力做出比餐馆更美味的蟹粉豆腐',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=203200306&idx=1&sn=9157ff78c140c0e285b62e61ad6d5594&scene=1&key=db7232c1ee4ed66d3e6ea39b56802bc82862a73bf676902074fdd8adfd8fb91729c91372960b3467dfb7fbd5267c46e8&ascene=0&uin=MTU5MDcxNDc0MA%3D%3D&pass_ticket=pHmn2MpUnuw%2F%2FiKj18%2B%2FgpxTb942%2FkLuNPkS5Y8DwO%2BSCIzxGvyQBR78t5PLJOYQ' },
//   { title: '做一碗上海最鲜美的虾肉小馄饨',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=200629985&idx=1&sn=658d55a9dc9ed82accffed684c604e4e&scene=1&key=56a02b69abdf3a9183858f9fdfe47a452bef89e5da848d74d124bf3b3845fe19940881f16a1e93bbbf1240f1585678c4&ascene=0&uin=MTU5MDcxNDc0MA%3D%3D&pass_ticket=pHmn2MpUnuw%2F%2FiKj18%2B%2FgpxTb942%2FkLuNPkS5Y8DwO%2BSCIzxGvyQBR78t5PLJOYQ' },
//   { title: '只有真正的吃货，才知道什么鱼好吃、刺少，又不贵……',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=400162477&idx=1&sn=8eafa19d35c45efababf992b7d882b11#rd' },
//   { title: '一口烤肉一口菠萝',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=229119991&idx=1&sn=d685edba748700850bccc3cef32ff515#rd' },
//   { title: '美国人早上怎么吃鸡蛋',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=227560279&idx=1&sn=e4e4cf853112707f43bef0f69edad953#rd' },
//   { title: '吃货过来，给小鲜肉来一枪',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=225960808&idx=1&sn=dc165cca5811fc5cd85adf58b3404d13#rd' },
//   { title: '这道海鲜面，好看更好吃',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=225120945&idx=1&sn=6d5c7e74d45ac4289089e194406650b8#rd' },
//   { title: '没想到，鸡蛋原来应该这样煮',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=223619305&idx=1&sn=735f7a8cbeda0217db5ca687d55d4887&scene=2&from=timeline&isappinstalled=0#rd' },
//   { title: '一个民族处理鸭肉的水平，代表了其料理的最高境界',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=223891406&idx=1&sn=4deb2f3a83e16e40cf377bcc3bb90e80&scene=1&from=groupmessage&isappinstalled=0#rd' },
//   { title: '这几天不吃这一口，就别说自己是吃货',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=211662200&idx=1&sn=f541e770f1ef7c6f6b1674a0e0d0dbc0&scene=2&from=timeline&isappinstalled=0#rd' },
//   { title: '茄子的日本吃法',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=224393153&idx=1&sn=c2e8773470645ba159a8905560157e7d&scene=2&from=timeline&isappinstalled=0#rd' },
//   { title: '夏天没胃口？试试这道日式生姜烧便当',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=224241603&idx=1&sn=f19fd792c13c8c0822af65a56bf83878&scene=2&from=timeline&isappinstalled=0#rd' },
//   { title: '这样做的冷饭，另一半天天吃都愿意',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=223145028&idx=1&sn=0855cbb600745fea344f1fde0dbfbab8&scene=2&from=timeline&isappinstalled=0#rd' },
//   { title: '有个中国人娶了个日本媳妇，每天中午这么吃',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=222916707&idx=1&sn=26af0ae796a7bddf49d6358f719cf207&scene=2&from=timeline&isappinstalled=0#rd' },
//   { title: '你们跑到海边，不就是想晒自己吃了海鲜大餐嘛',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=220227806&idx=1&sn=c0de3c2603a201622f7a1b7f63d9ff14&scene=1&key=c468684b929d2be268850f330802dc9a45f026a4884347dad0b6963ef6000bba3498b49aff0c7a116709d4e1e2278bf1&ascene=0&uin=MjQ0ODg0MTY2MQ%3D%3D&devicetype=iMac+MacBookPro10%2C1+OSX+OSX+10.10.2+build(14C1510)&version=11020012&pass_ticket=KN2ysZcsWWmB8bGtyKPl77GxN5AWRGYLZ7CT1W6YFVYK1lm0ImC72A1ALIIQrmZI' },
//   { title: '大鱼大肉也可以这样小清新',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=218187024&idx=1&sn=8e9d63424605520d55f702d9cdc722f2&scene=2&from=timeline&isappinstalled=0#rd' },
//   { title: '今晚只要红酒炖牛肉，谁也不约',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=219087278&idx=1&sn=c2ac084d1dfb61cb45c67dc29bc65390&scene=1&from=singlemessage&isappinstalled=0#rd' },
//   { title: '豆腐还可以这样吃，你绝对想不到',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=214951457&idx=1&sn=2446042b115141ab381d796b6007345d&scene=2&from=timeline&isappinstalled=0#rd' },
//   { title: '用家里的铁锅也能煎出世界上最好吃的三文鱼',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=205225548&idx=1&sn=c28131fcd18a8b05940d40123db8d7c8&scene=2&from=timeline&isappinstalled=0#rd' },
//   { title: '牛油果甜橙色拉，看着都让人心情愉快',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=203888661&idx=1&sn=2a65f7a6bea2aaf247788b18999255b6#rd' },
//   { title: '做这道菜，会让整个屋子都是香味',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=203422723&idx=1&sn=40a4f6c5a580e6b5af96263fb3be573d#rd' },
//   { title: '这个被周迅看中的小帅哥，最爱做饭……',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=404113864&idx=1&sn=3ec15b1d4cbd28711c0f36aff8b89c09#rd' },
//   { title: '要开心？来吃一份意式奶冻',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=225527341&idx=1&sn=72abaca92efb5780e62abcf5d08b1ba1#rd' },
//   { title: '爱自己，就为自己做一碗冰淇淋',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=224751963&idx=1&sn=86a8a4bbbfe020ece597049e4d81f547&scene=2&from=timeline&isappinstalled=0#rd' },
//   { title: '喜爱甜品又怕发胖？吃它就对了',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=224042341&idx=1&sn=8ea031a865c50a66bcf5e34c1c8b0b6c&scene=2&from=timeline&isappinstalled=0#rd' },
//   { title: '不要随便做给别人吃，除了你爱的、暗恋的',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=205251894&idx=1&sn=0c98610818495b9fc181cb60cd45416c#rd' },
//   { title: '在家也可以做出纯正欧洲范儿的芝士蛋糕',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=204637438&idx=1&sn=e109d96c3dc1c965b45ebf2d98cca986&scene=1&key=0dd6657c2b60679e86d92c5f94293ea735ca17c7a43256fa81917664fdc40daf4157e6664f6a6ba1293f58a30cc1e7a0&ascene=0&uin=MjQ0ODg0MTY2MQ%3D%3D&devicetype=iMac+MacBookPro10%2C1+OSX+OSX+10.9.5+build(13F34)&version=11020012&pass_ticket=koYpn8Cg5ih5J3FduDPXwAZgBXpAHEa7GGelNzPBU0YbAdyYWfDTseGv4%2FjVLGjw' },
//   { title: '勺子轻轻挖开，巧克力浓浆如熔岩缓缓流出',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=204362434&idx=1&sn=7e8e7588802b1b86701a54c10e649dd0&scene=1&key=0dd6657c2b60679e939d59f444bb4796527faada62dcb9c532d090e1bea6328ffdf7ca9858f3098bdc4eadbf9ba4f32b&ascene=0&uin=MjQ0ODg0MTY2MQ%3D%3D&devicetype=iMac+MacBookPro10%2C1+OSX+OSX+10.9.5+build(13F34)&version=11020012&pass_ticket=koYpn8Cg5ih5J3FduDPXwAZgBXpAHEa7GGelNzPBU0YbAdyYWfDTseGv4%2FjVLGjw' },
//   { title: '富贵全家福',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=209371428&idx=1&sn=47fcd375d6e0129c98f22dde0eeb3224#rd' },
//   { title: '甜烧白',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=209342062&idx=1&sn=165c858f93a1e1595015ad07713d00da#rd' },
//   { title: '萝卜丝肉丸',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=209313477&idx=1&sn=5f6282c15d7a89a24ad754605ad4a44c&scene=4#wechat_redirect' },
//   { title: '仁当牛肉',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=209283035&idx=1&sn=1e501995e0dae483cec0272cfc0f68f6#rd' },
//   { title: '九香贵妃鸡',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=209203464&idx=1&sn=afe92c05519fde20205ca61e7cf14f1f#rd' },
//   { title: '红烧大黄鱼',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=209133723&idx=1&sn=c60197f7732e27fa1153c31e444f6197#rd' },
//   { title: '百花酿鲜菇',
//     url: 'http://mp.weixin.qq.com/s?__biz=MjM5MDI5OTkyOA==&mid=209034135&idx=1&sn=b8b89e47e115e2d1b04c062b6056ef63&key=181de9050c6617b82e24d7a0c1cf55ba6188ad71f78bb121f8e2f9dc434aaee03273278ec4e9cf813c047536bce6c7bb&ascene=0&uin=MjQ0ODg0MTY2MQ%3D%3D&devicetype=iMac+MacBookPro10%2C1+OSX+OSX+10.10.2+build(14C109)&version=11020012&pass_ticket=IOYCwrDIU4rVSos7yajbzo72IO53lmV7og%2Ff8GHAehcHycu51eS2wjGG3WOCOJam' } ]



